package cn.com.darly.vpm.bizapi;

import cn.com.darly.vpm.framework.base.BaseController;
import cn.com.darly.vpm.framework.common.UuidGenerateUtil;
import cn.com.darly.vpm.security.securitycfg.SecurityApi;
import cn.com.darly.vpm.security.user.bean.User;
import cn.com.darly.vpm.security.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Author : ZhangYuHui
 * Date : 2017/12/1
 * TODO :
 */
@Service
public class SecurityBiz extends BaseController implements SecurityApi {


    @Autowired
    UserService userService;



    @Override
    public User findUserByLoginName(String username) {
        return userService.findUserByLoginName(username);
    }

    @Override
    public User findUserById(String id) {
        return userService.findUserByID(id);
    }

    @Override
    public List<String> getRoleListByUser(String id) {
        return userService.getRoleListByUser(id);
    }


    @Override
    public List<User> findUserLikeName(String username) {
       List<User> data =  userService.findUserLikeName(username);
       if (data!=null){
           for (User usr: data) {
               usr.setRoles("");
               usr.setPwd("");
               usr.setToken("");
           }
       }
        return data;
    }

    @Override
    public String rtmpUrlByUsername(String username,String friendname) {
        //獲取RTMP流媒體路徑
        String rtmp = rtmpHost+username+friendname+UuidGenerateUtil.getUUIDLong();
        return rtmp;
    }
}
